'''
Created on 2011-07-25
@author: XH
'''
from socket import *
from time import sleep
HOST='192.168.166.200'
PORT=21582
BUFSIZ=10240
ADDR=(HOST,PORT)
tcpCliSock=socket(AF_INET,SOCK_STREAM)
try:
    tcpCliSock.connect(ADDR)

except:
    print "Connect ERROR"
    tcpCliSock.close()


try:
    while True:
        data=raw_input('%s>>' %HOST)
        if not data:
            break
        elif data == "exit":
            print "ENTER OUT OUT OK OK!!! "
            break
        elif data == "quit":
            print "ENTER OUT OUT OK OK!!! "
            break
        tcpCliSock.send(data)
        sleep(0.5)
        data=tcpCliSock.recv(BUFSIZ)
        print data

    tcpCliSock.close()

except KeyboardInterrupt:
    tcpCliSock.close()
